<template>
    <div class="content">
        <div @click="sub">-</div>
        <div>{{count}}</div>
        <div @click="add">+</div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            count:1
        }
    },
    created() {
    },
    methods: {
        sub(){
             this.count--;
            if(this.count <1){
                this.count = 1;
            }
               this.sentdata();
            
            // this.count = this.count>1?(this.count--):1;
        },
        add(){
            this.count++;
            this.sentdata();
        },
        sentdata(){
            this.$emit('dataobj',this.count);
        }
    }
}
</script>
<style scoped>
.content{
    display: inline-block;
}
    .content div{
        width: 40px;
        height: 20px;
        border: 1px solid #000;
        display: inline-block;
        text-align: center;
    }
</style>